<!-- TODO: hyy -->
<script setup>
/**
 * @libs
 */
import { nextTick, ref } from 'vue'

/**
 * @data
 */
let compMess = ref({
  'exploreMore': {
    "bgImg": "img_1.png",
    "title": "神秘的盒子",
    "subtitle":"总价值超过35元/70元，现在只需5.44元/11.44元",
    "content": "我们将根据季节或节日场合更新幸运袋内容（大约一个月一次）",
    "buttonText": "探索更多",
    "link": $szcyydsUrl,
    //是否新标签跳转
    "isNewTab": false,
  },
  "right": {
    "background-image": "img_2.png"
  }
})

/**
 * 返回指定文件夹下的图片路径
 * @param {String} name 图片名称
 * @returns {String} 图片路径
 */
let getImgUrl = (name) => {
  return new URL(`/src/assets/images/mainImgs/homeImgs/part_4_imgs/${name}`, import.meta.url).href
}

/**
 * 返回探索更多动态样式类
 * @returns {Object}
 */
let exportMoreBgClass = () => {
  return {
    backgroundImage: `url(${getImgUrl(compMess.value['exploreMore'].bgImg)})`,
    backgroundSize: "cover",
    backgroundPosition: "center",
    backgroundRepeat: "no-repeat",
  }
}

/**
 * 链接跳转事件
 * @param {Boolean} isNewTab 是否新标签跳转
 * @param {String} link 链接地址
 */
let gotoNavtion = (isNewTab, link) => {
  if (isNewTab) {
    window.open(link)
  } else {
    window.location.href = link
  }
}

/**
 * 探索更多按钮点击事件
 * @param {Boolean} isNewTab 是否新标签跳转
 */
let exportMoreButtonEvent = (isNewTab) => {
  gotoNavtion(isNewTab, compMess.value['exploreMore'].link)
}
</script>
<template>
  <div class="part-4-class">
    <div class="part-4-explore-more" :style="exportMoreBgClass()">
      <div class="part-4-explore-more-title">{{ compMess['exploreMore'].title }}</div>
      <div class="part-4-explore-more-subtitle">{{ compMess['exploreMore'].subtitle }}</div>
      <div class="part-4-explore-more-content">{{ compMess['exploreMore'].content }}</div>
      <div class="part-4-explore-more-btn" @click="exportMoreButtonEvent(compMess['exploreMore'].isNewTab)">{{
        compMess['exploreMore'].buttonText }}</div>
    </div>
    <div class="part-4-img-box">
      <img class="part-4-img-box-img" :src="getImgUrl(compMess['right']['background-image'])" alt="" srcset="">
    </div>
  </div>
</template>
<style scoped>
.part-4-class {
  width: 14rem;
  margin: 0 auto;
  height: 4.2rem;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  cursor: pointer;
  margin-top: 1rem;
  border-radius: 0.32rem;
  background-color: #6BC2B4;
  overflow: hidden; 
}


.part-4-img-box {
  width: 10rem;
  height: 4.2rem;
}

.part-4-img-box-img {
  width: 100%;
}


.part-4-explore-more{
  position: relative;
  width: 5.74rem;
  height: 2.59rem;
  margin: 0.75rem;
  z-index: 1;
}
.part-4-explore-more::before {
  content: '';
  position: absolute;
  top: -1.8rem;
  left: 1rem;
  width: 6.3rem;
  height: 6.3rem;
  border-radius: 50%;
  background-color: #6BC2B4;
  z-index: -1;
}

.part-4-explore-more-title {
  width: 2.24rem;
  height: 0.59rem;
  font-weight: 600;
  font-size: 0.36rem;
  line-height: 0.54rem;
  color: #fff;
  margin-bottom: 0.1rem;
}

.part-4-explore-more-subtitle {
  width: 5.74rem;
  height: 0.36rem;
  font-weight: 400;
  font-size: 0.24rem;
  line-height: 0.36rem;
  color: #fff;
  margin-bottom: 0.1rem;
}

.part-4-explore-more-content {
  width: 5.15rem;
  height: 0.48rem;
  opacity: 0.7;
  font-weight: 400;
  font-size: 0.16rem;
  line-height: 0.24rem;
  color: #fff;
  /* 超出两行则省略号 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  /* 限制显示两行 */
  -webkit-box-orient: vertical;
  /* 设置为垂直排列 */
  overflow: hidden;
  /* 超出内容隐藏 */
  text-overflow: ellipsis;
  /* 显示省略号 */
  line-clamp: 2;
  /* 添加标准属性 */
}

.part-4-explore-more-btn {
  width: 1.6rem;
  height: 0.48rem;
  border-radius: 0.4rem;
  background-color: #fff;
  border: #fff solid 0.01rem;
  font-weight: 400;
  font-size: 0.16rem;
  color: black;
  text-align: center;
  line-height: calc(0.48rem - 0.02rem);
  margin-top: 0.5rem;
}
.part-4-img-box-img{
  width: 9rem;
  height: 4.2rem;
  border-radius-right: 0.32rem;
  object-fit: cover;
}
</style>